home *** CD-ROM | disk | FTP | other *** search
- Path: cymbal.aix.calpoly.edu!not-for-mail
- From: dstubbs@cymbal.aix.calpoly.edu (Dan Stubbs)
- Newsgroups: comp.lang.c
- Subject: Re: Limit on #bytes inside of struct?
- Date: 9 Feb 1996 09:02:31 -0800
- Organization: California Polytechnic State University, San Luis Obispo
- Message-ID: <4ffun7$1l4l@cymbal.aix.calpoly.edu>
- References: <4feg1d$d4g@cville-srv.wam.umd.edu> <4ffg6b$ivd@sparcserver.lrz-muenchen.de> <4ffohq$1gb@mordred.gatech.edu>
- NNTP-Posting-User: dstubbs@cymbal.aix.calpoly.edu
-
- In article <4ffohq$1gb@mordred.gatech.edu>,
- James McIninch <james@amber.biology.gatech.edu> wrote:
- >ua302aa@lrz-muenchen.de wrote:
- >: jsquires@wam.umd.edu (jeffrey d squires) writes:
- >
- >: >I have the following:
- >
- >: >typedef struct {
- >: > int zero;
- >: > int one;
- >: > int two;
- >: > int three;
- >: > int four;
- >: > int five;
- >: > int six;
- >: > int seven_or_more;
- >: >} hist_type;
- >
- >: >hist_type histogram;
- >: >int num=2;
- >: >histogram.four = 0; /* at this point, value of num changes from 2 to 0!!!*/
- >: >Is there a limit on the number of bytes allowed inside of a struct?
- >
- >: Yes, there is a limit on the number of bytes allowed in one
- >: object. That limit is 32k.
- >
- >No. There is no limit. Individual implementations of compilers or OS's may
- >impose a limit, but there is no limit that is integral to the C languag itself.
- >
-
- Here is a specific program to test the above suggestions.
-
- #include <stdio.h>
- int main () {
-
- typedef struct {
- int the_array[50000];
- } struct_type;
-
- int k;
- struct_type the_struct;
- int num = 2;
-
- puts ("Test Started");
- for (k=0; k<50000; k++) {
- the_struct.the_array[k] = 0;
- if (num != 2)
- printf (" k = %d\n", k);
- }
- puts ("Test Complete");
- }
-
- I ran this in a UNIX environment on two different architectures using
- both gcc and c89 compilers. The value of num was not changed in any of
- these cases. As others have noted, this is what you would expect.
-
-